]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
calendar-server: Remove the all-day property of events
authorSebastian Keller <skeller@gnome.org>
Thu, 4 Nov 2021 16:07:50 +0000 (17:07 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 30 Nov 2021 02:13:24 +0000 (02:13 +0000)
The way it is currently calculated is broken for days with DST changes
or leap seconds and it is not needed anymore anyway. This will also make
the fix in the following commit simpler.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2023>

data/dbus-interfaces/org.gnome.Shell.CalendarServer.xml
js/ui/calendar.js
src/calendar-server/gnome-shell-calendar-server.c

index 51b71ef03e1d81b188dd5f0795eef097790b1312..581471016d220b3a37192e2c1fa0e245c285bf29 100644 (file)
@@ -6,7 +6,7 @@
       <arg type="b" name="force_reload" direction="in"/>
     </method>
     <signal name="EventsAddedOrUpdated">
-      <arg type="a(ssbxxa{sv})" name="events" direction="out"/>
+      <arg type="a(ssxxa{sv})" name="events" direction="out"/>
     </signal>
     <signal name="EventsRemoved">
       <arg type="as" name="ids" direction="out"/>
index a42d70ffb2de86314b64c6dcd19269fddd52211a..852f1d0fe2df50ac9bd136d82742d30af83eee15 100644 (file)
@@ -78,12 +78,11 @@ function _getCalendarDayAbbreviation(dayNumber) {
 // Abstraction for an appointment/event in a calendar
 
 var CalendarEvent = class CalendarEvent {
-    constructor(id, date, end, summary, allDay) {
+    constructor(id, date, end, summary) {
         this.id = id;
         this.date = date;
         this.end = end;
         this.summary = summary;
-        this.allDay = allDay;
     }
 };
 
@@ -288,10 +287,10 @@ class DBusEventSource extends EventSourceBase {
         let changed = false;
 
         for (let n = 0; n < appointments.length; n++) {
-            const [id, summary, allDay, startTime, endTime] = appointments[n];
+            const [id, summary, startTime, endTime] = appointments[n];
             const date = new Date(startTime * 1000);
             const end = new Date(endTime * 1000);
-            let event = new CalendarEvent(id, date, end, summary, allDay);
+            let event = new CalendarEvent(id, date, end, summary);
             this._events.set(event.id, event);
 
             changed = true;
index 4c5a64542b2dad86a7346ecd51346f571255b71a..c8e2eafafe00ea127a0df8dba715fe2d9f0c8d26 100644 (file)
@@ -52,7 +52,7 @@ static const gchar introspection_xml[] =
   "      <arg type='b' name='force_reload' direction='in'/>"
   "    </method>"
   "    <signal name='EventsAddedOrUpdated'>"
-  "      <arg type='a(ssbxxa{sv})' name='events' direction='out'/>"
+  "      <arg type='a(ssxxa{sv})' name='events' direction='out'/>"
   "    </signal>"
   "    <signal name='EventsRemoved'>"
   "      <arg type='as' name='ids' direction='out'/>"
@@ -110,7 +110,6 @@ typedef struct
   gchar  *summary;
   time_t  start_time;
   time_t  end_time;
-  guint   is_all_day : 1;
 } CalendarAppointment;
 
 static time_t
@@ -175,51 +174,6 @@ get_ical_end_time (ECalClient    *cal,
                                  default_zone);
 }
 
-static gboolean
-get_ical_is_all_day (ECalClient    *cal,
-                     ICalComponent *icomp,
-                     time_t         start_time,
-                     ICalTimezone  *default_zone)
-{
-  ICalProperty *prop;
-  ICalDuration *duration;
-  ICalTime     *dtstart;
-  struct tm    *start_tm;
-  time_t        end_time;
-  gboolean      retval;
-
-  dtstart = i_cal_component_get_dtstart (icomp);
-  if (dtstart && i_cal_time_is_date (dtstart))
-    {
-      g_clear_object (&dtstart);
-      return TRUE;
-    }
-
-  g_clear_object (&dtstart);
-
-  start_tm = gmtime (&start_time);
-  if (start_tm->tm_sec  != 0 ||
-      start_tm->tm_min  != 0 ||
-      start_tm->tm_hour != 0)
-    return FALSE;
-
-  if ((end_time = get_ical_end_time (cal, icomp, default_zone)))
-    return (end_time - start_time) % 86400 == 0;
-
-  prop = i_cal_component_get_first_property (icomp, I_CAL_DURATION_PROPERTY);
-  if (!prop)
-    return FALSE;
-
-  duration = i_cal_property_get_duration (prop);
-
-  retval = duration && (i_cal_duration_as_int (duration) % 86400) == 0;
-
-  g_clear_object (&duration);
-  g_clear_object (&prop);
-
-  return retval;
-}
-
 static CalendarAppointment *
 calendar_appointment_new (ECalClient    *cal,
                           ECalComponent *comp)
@@ -241,10 +195,6 @@ calendar_appointment_new (ECalClient    *cal,
   appt->summary     = g_strdup (i_cal_component_get_summary (ical));
   appt->start_time  = get_ical_start_time (cal, ical, default_zone);
   appt->end_time    = get_ical_end_time (cal, ical, default_zone);
-  appt->is_all_day  = get_ical_is_all_day (cal,
-                                           ical,
-                                           appt->start_time,
-                                           default_zone);
 
   e_cal_component_id_free (id);
 
@@ -361,7 +311,7 @@ app_notify_events_added (App *app)
   /* The a{sv} is used as an escape hatch in case we want to provide more
    * information in the future without breaking ABI
    */
-  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ssbxxa{sv})"));
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ssxxa{sv})"));
   for (link = events; link; link = g_slist_next (link))
     {
       CalendarAppointment *appt = link->data;
@@ -375,10 +325,9 @@ app_notify_events_added (App *app)
         {
           g_variant_builder_init (&extras_builder, G_VARIANT_TYPE ("a{sv}"));
           g_variant_builder_add (&builder,
-                                 "(ssbxxa{sv})",
+                                 "(ssxxa{sv})",
                                  appt->id,
                                  appt->summary != NULL ? appt->summary : "",
-                                 (gboolean) appt->is_all_day,
                                  (gint64) start_time,
                                  (gint64) end_time,
                                  &extras_builder);
@@ -390,7 +339,7 @@ app_notify_events_added (App *app)
                                  "/org/gnome/Shell/CalendarServer",
                                  "org.gnome.Shell.CalendarServer",
                                  "EventsAddedOrUpdated",
-                                 g_variant_new ("(a(ssbxxa{sv}))", &builder),
+                                 g_variant_new ("(a(ssxxa{sv}))", &builder),
                                  NULL);
 
   g_variant_builder_clear (&builder);